package com.iflytek.nacos.discovery.biz;



import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



import java.util.List;



/**
 * @program: springCloudAlibaba
 * @description:
 * @author: 陈亮
 * @create: 2022-01-17 20:56
 */
@RestController
@RequestMapping("/discovery")
public class DiscoveryBiz {

    @NacosInjected
    private NamingService namingService;

    //http://localhost:8082/discovery/get?serviceName=example
    @GetMapping(value = "/get")
    public List<Instance> get(@RequestParam String serviceName) throws NacosException {
        return namingService.getAllInstances(serviceName);
    }


}
